package com.example.exceldemo.controller;

import com.example.exceldemo.service.EasyPoiService;
import com.example.exceldemo.service.WordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @Description
 * @Author xiaohuang
 * @Date 2024/7/10
 */
@RequestMapping("excelPoi")
@Api(tags = "excelPoi导出")
@RestController
public class EasyPoiExcelExpController {
    @Autowired
    private EasyPoiService easyPoiService;
    @Resource
    private WordService wordService;

    @GetMapping("autowiredExp")
    @ApiOperation(value = "excel普通注解导出", produces = "application/octet-stream")
    public void downloadTemplate() {
        easyPoiService.autowiredExp();
    }

    @GetMapping("autowiredObjExp")
    @ApiOperation(value = "excel普通注解导出-对象中包含对象", produces = "application/octet-stream")
    public void autowiredObjExp() {
        easyPoiService.autowiredObjExp();
    }

    @GetMapping("autowiredListExp")
    @ApiOperation(value = "excel普通注解导出-对象中包含列表（合并单元格）", produces = "application/octet-stream")
    public void autowiredListExp() {
        easyPoiService.autowiredListExp();
    }

    @GetMapping("autowiredImageExp")
    @ApiOperation(value = "excel普通注解导出-包含图片）", produces = "application/octet-stream")
    public void autowiredImageExp() {
        easyPoiService.autowiredImageExp();
    }

    @GetMapping("autowiredBigExp")
    @ApiOperation(value = "excel大量数据分批数据导出（多sheet）", produces = "application/octet-stream")
    public void autowiredBigExp() {
        easyPoiService.autowiredBigExp();
    }

    @GetMapping("bigExp")
    @ApiOperation(value = "excel大量数据分批数据导出（单sheet）", produces = "application/octet-stream")
    public void bigExp() {
        easyPoiService.bigExp();
    }

    @PostMapping("importPoi")
    @ApiOperation(value = "excel导入", produces = "application/octet-stream")
    public void importPoi(@RequestBody MultipartFile file) {
        easyPoiService.importPoi(file);
    }

    @GetMapping("wordExportTemplate")
    @ApiOperation(value = "docx模板导出", produces = "application/octet-stream")
    public void exportTemplate() {
        wordService.exportTemplate();
    }

    @GetMapping("excelExportTemplate")
    @ApiOperation(value = "excel单个sheet模板导出", produces = "application/octet-stream")
    public void excelExportTemplate() {
        easyPoiService.excelExportTemplate();
    }

    @GetMapping("excelExportTemplates")
    @ApiOperation(value = "excel多个sheet模板导出", produces = "application/octet-stream")
    public void excelExportTemplates() {
        easyPoiService.excelExportTemplates();
    }

    @GetMapping("initExcel")
    @ApiOperation(value = "自定义导出excel", produces = "application/octet-stream")
    public void initExcel() {
        easyPoiService.initExcel();
    }

}
